Ext.define('PJ.view.registrationmanagement.AChooseUserFrame', {
    extend: 'Ext.container.Container',
    alias: ['widget.signUpChooseUserFrame'],
    layout: 'border',
    // 必须增加这段，强制提前加载类，这样才可以使用简写
    requires: ['PJ.view.registrationmanagement.ChooseUserRightFrame', 'PJ.view.registrationmanagement.BaseCategoryTree'],
    verflowX:"hidden",
    overflowY:"scroll",
    items: [{
        region: 'west',
    	width: 200,
        height: 540,
        xtype: "baseCategoryTree",
        title: "组织机构树",
        collapsible: true,
        border:false,
        listeners: {
        	//显示树的一级菜单
    		load: function(treeStore, node, records, successful, eOpts){
    			if (node.data.id==1&&records != null&&node.hasChildNodes()) {
    				if(node.data.id==1)
    					this.fireEvent("itemclick",this.view,records[0]); //点击展开节点
    			}
    		},
            itemclick: function(view, record, htmlelement, index, eventObject, object){
            	if(eventObject){
            		eventObject.stopEvent();
            	}
                var preChooseUserList = this.up("container").down("signUpChooseUserRightFrame").down("signUpPreChooseUserList");
				var choosedUserList = this.up("container").down("signUpChooseUserRightFrame").down("signUpChoosedUserList");
                preChooseUserList.queryUnitId = record.data.id;
                choosedUserList.queryUnitId = record.data.id;
                // 设置grid可以被刷新等功能
                preChooseUserList.isPossibleLoad = true;
                choosedUserList.isPossibleLoad = true;
                // grid加载生效
                preChooseUserList.store.isLoad = true;
                choosedUserList.store.isLoad = true;
                var preStore = preChooseUserList.getStore();
                var chooseStore = choosedUserList.getStore();
                var newParams = {
                		searchDepId: record.data.id,
                		searchClassID: preChooseUserList.up("window").trainingGradeId
                };
                // 重置翻页属性
                preChooseUserList.resetPage();
                choosedUserList.resetPage();
                // 重置查询
//                preChooseUserList.down("#resetButton").fireEvent('click');
//                choosedUserList.down("#resetButton").fireEvent('click');
                // 4.0强制更改store参数写法
                var params = preStore.proxy.extraParams;
                Ext.apply(params, newParams);
                preStore.load();
                params = chooseStore.proxy.extraParams;
                var trainingGradeId = this.up("container").up('window').trainingGradeId;
                Ext.apply(params, {searchDepId: record.data.id,searchClassID:trainingGradeId});
                chooseStore.load();
            }
        }
    }, {
    	region: 'center',
        xtype: 'signUpChooseUserRightFrame',
        width: 688,
        height: 540
    }]
});
